package com.design_pattern.stragery;

import com.peng.Bullet;
import com.peng.Dir;
import com.peng.Tank;

public class DeafultFireStraery implements FireStragery {
    private static final DeafultFireStraery instance = new DeafultFireStraery();

    private DeafultFireStraery() {

    }

    public static DeafultFireStraery getInstance() {
        return instance;
    }

    @Override
    public void fire(Tank tank) {
        //子弹出现于坦克的正中心
        //就写了一个斜方向的 测试一下就完事了
        if (tank.getDir() == Dir.RU) {
            new Bullet(tank.getX() + tank.getWidth() + 10, tank.getY() + Tank.HEIGHT + Bullet.HEIGHT - Bullet.HEIGHT - 60, tank.getDir(), tank.getGroup());
            return;
        }
        int bX = tank.getX() + tank.getWidth() / 2 - Bullet.WIDTH / 2;
        int bY = tank.getY() + Tank.HEIGHT / 2 - Bullet.HEIGHT / 2;
        new Bullet(bX, bY, tank.getDir(), tank.getGroup());
    }
}
